package com.quad.innovators.salesease.converter;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.quad.innovators.salesease.common.result.PageResultBean;
import com.quad.innovators.salesease.model.entity.task.TaskDistribution;
import com.quad.innovators.salesease.model.form.task.TaskDistributionForm;
import com.quad.innovators.salesease.model.vo.task.TaskDistributionVO;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

/**
 * 任务发布对象转换器
 * @author cheng
 */
@Mapper(componentModel = "spring")
public interface TaskDistributionConverter {

    @Mappings({
            @Mapping(target = "items", source = "records"),
            @Mapping(target = "pageInfo.currPage", source = "current"),
            @Mapping(target = "pageInfo.totalCount", source = "total"),
            @Mapping(target = "pageInfo.pageSize", source = "size")
    })
    PageResultBean<TaskDistributionVO> toPageVo(Page<TaskDistributionVO> bo);

    @Mappings({
            @Mapping(target = "startTime" , source = "startTime"),
            @Mapping(target = "deadline" , source = "deadline"),
    })
    TaskDistributionForm toForm(TaskDistribution entity);

    @InheritInverseConfiguration(name = "toForm")
    TaskDistribution toEntity(TaskDistributionForm entity);

}
